Imports Softelvdm.Controls
Imports Softelvdm.SftTabsNET

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' This sample demonstrates how the various parts of a tab control are used in tabs.
    ' To prepare for this sample, create a new project with a blank form and add
    ' a SftTabs/NET control named sftTabs1.
    ' In addition, adjust the following FromFile method to use a (small) bitmap
    ' that is located on your system.

    Dim img1 As Image = Bitmap.FromFile("..\\..\\test1.png")
    Dim img2 As Image = Bitmap.FromFile("..\\..\\test2.png")

    sftTabs1.Initializing = True

    ' First Tab
    Dim tab As TabClass = sftTabs1.TabCollection.Add()
    tab.Orientation = OrientationOptionalEnum.Vertical
    Dim textPart As TextPartClass = New TextPartClass("&First Tab")
    textPart.PartAlignment = PartAlignmentEnum.Center
    textPart.HAlign = HAlignmentOptionalEnum.Center
    tab.Parts.Add(textPart)
    Dim imagePart As ImagePartClass = New ImagePartClass(img1)
    imagePart.PartAlignment = PartAlignmentEnum.Center
    imagePart.HAlign = HAlignmentOptionalEnum.Center
    tab.Parts.Add(imagePart)

    ' Second Tab
    tab = sftTabs1.TabCollection.Add()
    Dim buttonPart As ButtonPartClass = New ButtonPartClass()
    buttonPart.Text = ">"
    AddHandler buttonPart.Action, AddressOf buttonPart_Action
    buttonPart.PartAlignment = PartAlignmentEnum.Center
    tab.Parts.Add(buttonPart)
    Dim checkboxPart As CheckBoxPartClass = New CheckBoxPartClass(CheckBoxStateEnum.Checked)
    checkboxPart.PartAlignment = PartAlignmentEnum.Center
    AddHandler checkboxPart.Action, AddressOf checkboxPart_Action
    tab.Parts.Add(checkboxPart)
    textPart = New TextPartClass("Tab &Two")
    textPart.PartAlignment = PartAlignmentEnum.Center
    textPart.BackColorSelected = Color.Green
    textPart.Angle = 315
    tab.Parts.Add(textPart)

    ' Third Tab
    tab = sftTabs1.TabCollection.Add()
    textPart = New TextPartClass("Third Tab (&3)")
    textPart.PartAlignment = PartAlignmentEnum.Center
    tab.Parts.Add(textPart)
    imagePart = New ImagePartClass()
    imagePart.Image = img2
    imagePart.VisibleAppearance = VisibleAppearanceEnum.OwnerSelected
    imagePart.PartAlignment = PartAlignmentEnum.Center
    tab.Parts.Add(imagePart)

    ' Make the first tab active
    sftTabs1.Current = 0

    sftTabs1.Initializing = False

End Sub

Private Sub checkboxPart_Action(ByVal sender As Object, ByVal e As ActionEventArgs)
    ' A checkbox part automatically checks/unchecks the checkbox, and
    ' it automatically makes the containing tab the selected tab.
    ' To prevent the tab from being selected, use the CancelMode method:
    sftTabs1.CancelMode()
End Sub

Private Sub buttonPart_Action(ByVal sender As Object, ByVal e As ActionEventArgs)
    Dim tab As TabClass = e.Part.PartOwner
    MessageBox.Show("The button was clicked")
    ' A button part automatically makes the containing tab the selected tab.
    ' But, because we changed the input focus using the message box above,
    ' tab switching was cancelled. So, we can explicitly make the tab
    ' the selected tab, if desired:
    sftTabs1.Current = tab.Index
End Sub

End Class